package com.dwy2002.appointment;

import com.dwy2002.appointment.config.CorsProperties;
import com.dwy2002.appointment.listener.ApplicationStartingEventListener;
import com.dwy2002.common.config.MyOssConfig;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.time.Instant;

@SpringBootApplication
@EnableScheduling //开启定时任务支持
@EnableConfigurationProperties({MyOssConfig.class, CorsProperties.class})
//用于指定MyBatis的Mapper接口所在的包路径，让Spring Boot自动扫描并注册这些接口为MyBatis的Mapper。
@MapperScan({
        "com.dwy2002.course.mapper",
        "com.dwy2002.room.mapper",
        "com.dwy2002.product.mapper",
        "com.dwy2002.user.mapper",
        "com.dwy2002.order.mapper",
        "com.dwy2002.refund.mapper",
        "cn.dwy2002.task.mapper",
})
//用于指定Spring框架需要扫描的组件（如@Component、@Service、@Controller、@Repository等）所在的包路径,spring boot默认会扫描com.example包及其子包，但由于进行了父子分离项目，所以需要指定路径扫描
@ComponentScan(basePackages = {
        "com.dwy2002.appointment",      // 主项目包路径
        "com.dwy2002.common",     // common-module 的包路径
        "com.dwy2002.course",   //course-module 的包路径
        "com.dwy2002.room",      //room-module 的包路径
        "com.dwy2002.product",    //product-module 的包路径
        "com.dwy2002.user",    //user-module 的包路径
        "com.dwy2002.order",    //order-module 的包路径
        "com.dwy2002.refund",    //order-module 的包路径
        "cn.dwy2002.task",    //task-module 的包路径
})
public class Application {

//    public static void main(String[] args) {
//        SpringApplication.run(Application.class, args);
//    }

    public static void main(String[] args) {
        SpringApplication app = new SpringApplication(Application.class);
        ApplicationStartingEventListener listener = new ApplicationStartingEventListener();
        app.addListeners(listener);
        app.run(args);
        System.out.println("应用启动总耗时：" + (Instant.now().toEpochMilli() - listener.getStartTime()) + " ms");
    }

}
/*
 *                    _ooOoo_
 *                   o8888888o
 *                   88" . "88
 *                   (| -_- |)
 *                    O\ = /O
 *                ____/`---'\____
 *              .   ' \\| |// `.
 *               / \\||| : |||// \
 *             / _||||| -:- |||||- \
 *               | | \\\ - /// | |
 *             | \_| ''\---/'' | |
 *              \ .-\__ `-` ___/-. /
 *           ___`. .' /--.--\ `. . __
 *        ."" '< `.___\_<|>_/___.' >'"".
 *       | | : `- \`.;`\ _ /`;.`/ - ` : | |
 *         \ \ `-. \_ __\ /__ _/ .-` / /
 * ======`-.____`-.___\_____/___.-`____.-'======
 *                    `=---='
 * <p>
 * .............................................
 *          佛祖保佑             永无BUG
 *     Blessed by Buddha  never encounter bugs
 */